#ifndef _BUILDER_PLUGIN_CONTROL_H
#define _BUILDER_PLUGIN_CONTROL_H

#include "builderplugin.h"

#ifdef __cplusplus
extern "C"{
#endif

typedef enum
{
	BUILDER_RECV_SDT,
	BUILDER_RECV_PAT,
	BUILDER_RECV_PMT,
}BUILDER_SECTION_RECV_TYPE_T;

typedef enum
{
	BUILDER_SECTION_DATA_NOSDT_STOP = 0,
	BUILDER_SECTION_DATA_NOSDT_CONTINUE = 1,
}BUILDER_SECTION_RECV_CONFIG_T;

typedef struct
{
	BUILDER_SECTION_RECV_CONFIG_T 	m_eSecRecvCfg;
	unsigned short					m_u16PSITimeoutRatio;
	unsigned short					m_u16SITimeoutRatio;
}builder_section_control_cfg_t;

#define PMT_RECV_FILTER_MAX_NUM	16

typedef struct
{
	BUILDER_SECTION_RECV_TYPE_T 	m_eType;
	builder_sipsi_t					m_stSiPsi;
	unsigned char 					m_au8SecRecvBitmap[256];
	unsigned int						m_u32Filter;
	unsigned int						m_u32PmtIndex;
	unsigned int						m_u32RecvDataTimes;
	unsigned int						m_u32Timeout;
	unsigned int						m_au32PmtTimeout[PMT_RECV_FILTER_MAX_NUM];
	unsigned int						m_au32PmtFilter[PMT_RECV_FILTER_MAX_NUM];
}builder_section_control_t;


extern int PluginSectionDataStart(builder_section_control_t* pstSectionRecvCntrl);
extern int PluginSectionDataTick(builder_section_control_t* pstSectionRecvCntrl);
extern int PluginSectionDataRecv(builder_section_control_t* pstSectionRecvCntrl, unsigned int hFilter, unsigned char* pu8Section);
extern int PluginSectionDataGetProcess(builder_section_control_t* pstSectionRecvCntrl, unsigned int* pu32Process);
extern int PluginSectionDataStop(builder_section_control_t* pstSectionRecvCntrl);
extern int PluginSectionDataReset(builder_section_control_t* pstSectionRecvCntrl);
extern int PluginSectionDataGetSections(builder_section_control_t* pstSectionRecvCntrl, builder_sipsi_t* pstSiPsi);
extern int PluginSectionDataSetConfig(builder_section_control_t* pstSectionRecvCntrl, builder_section_control_cfg_t* pstCfg);

//temporary export
extern int PluginSecFinishCheck(unsigned char* pu8RecvBitmap, unsigned char u8LastSecNo, unsigned char u8CurSecNo);
extern int PluginSecRecvCheck(unsigned char* pu8RecvBitmap, unsigned char u8CurSecNo);
extern int PluginSecRecvCount(unsigned char* pu8RecvBitmap, unsigned char u8LastSectionNum);


#ifdef __cplusplus
}
#endif

#endif //_BUILDER_PLUGIN_CONTROL_H
